Add an option to xmtest to report results to an alternative results repository.
authorpl@us.ibm.com <pl@us.ibm.com>
Tue, 21 Mar 2006 00:19:24 +0000 (01:19 +0100)
committerpl@us.ibm.com <pl@us.ibm.com>
Tue, 21 Mar 2006 00:19:24 +0000 (01:19 +0100)
The default is preserved but can be overridden by either passing it with -r to runtest.sh or by setting the xmtest_repo environment variable.

Signed-off-by: Paul Larson <pl@us.ibm.com>
tools/xm-test/lib/XmTestReport/Report.py
tools/xm-test/runtest.sh

index 43097bbc833f6cec2d80f27bcf320ac93b469d3f..92412b8770a2b3a5c73380c837e44e8fc622a0f9 100644 (file)
@@ -32,11 +32,7 @@ import xml.dom.minidom
 import httplib
 import urllib
 import re
-
-#REPORT_HOST = "xmtest-dev.dague.org"
-REPORT_HOST = "xmtest.dague.org"
-REPORT_URL  = "/cgi-bin/report-results";
-VIEW_URL = "cgi-bin/display?view=single&testid="
+from urlparse import urlparse
 
 class XmTestReport:
 
@@ -88,8 +84,11 @@ def encodeForm(fieldList):
 
     return 'multipart/form-data; boundary=%s' % boundary, textBody
 
-def postResults(results):
-    conn = httplib.HTTPConnection(REPORT_HOST)
+def postResults(report_server, results):
+    if not re.match('http://', report_server):
+       report_server = 'http://'+report_server
+    (report_host,report_url) = urlparse(report_server)[1:3]
+    conn = httplib.HTTPConnection(report_host)
 
     type, body = encodeForm({"log" : results})
 
@@ -100,22 +99,17 @@ def postResults(results):
     # print "%s\n" % type
     # print headers
     
-    conn.request("POST", REPORT_URL, body, headers)
+    conn.request("POST", report_url, body, headers)
     
     resp = conn.getresponse()
     data = resp.read()
 
     if resp.status == 200:
         print >>sys.stderr, "Your results have been submitted successfully!"
-        match = re.match("^id=([0-9]+)$", data.split("\n")[1])
-        if match:
-            id = match.group(1)
-            print >>sys.stderr, "See your report at:"
-            print >>sys.stderr, "http://%s/%s%s" % (REPORT_HOST, VIEW_URL, id)
     else:
         print >>sys.stderr, "Unable to submit results:"
-        print >>sys.stderr, "[http://%s%s] said %i: %s" % (REPORT_HOST,
-                                                           REPORT_URL,
+        print >>sys.stderr, "[http://%s%s] said %i: %s" % (report_host,
+                                                           report_url,
                                                            resp.status,
                                                            resp.reason)
         print >>sys.stderr, data
@@ -133,7 +127,9 @@ if __name__ == "__main__":
     dump = False
     files = []
 
-    for a in sys.argv[1:]:
+    report_server = sys.argv[1]
+
+    for a in sys.argv[2:]:
         if a == "-d":
             submit = False
             dump = True
@@ -156,5 +152,5 @@ if __name__ == "__main__":
         print xmlout
 
     if submit:
-        postResults(xmlout)
+        postResults(report_server, xmlout)
     
index f35e9ca45aff2765b0a6653b80b1e1bd66063b58..2cedec6440d50a668b975408f39eec216b860652 100755 (executable)
@@ -13,6 +13,7 @@ usage() {
     echo "  -b          : do not ask any questions (batch mode)"
     echo "  -g          : run a group test set"
     echo "  -e <email>  : set email address for report"
+    echo "  -r <url>    : url of test results repository to use"
     echo "  -s <report> : just submit report <report>"
     echo "  -h | --help : show this help"
 }
@@ -22,7 +23,7 @@ submit_report() {
 
     reportfile=$1
 
-    ./lib/XmTestReport/Report.py $reportfile
+    ./lib/XmTestReport/Report.py $reportserver $reportfile
 }
 
 # Generate XML result report from output file
@@ -189,6 +190,7 @@ EOF
 # Defaults
 MAXFAIL=10
 report=yes
+reportserver=${xmtest_repo:-'http://xmtest.dague.org/cgi-bin/report-results'}
 batch=no
 run=yes
 GROUPENTERED=default
@@ -218,6 +220,10 @@ while [ $# -gt 0 ]
              exit 1
           fi
          ;;
+      -r)
+         shift
+         reportserver=$1
+         ;;
       -s)
          run=no
          ;;